package com.cxhc.system.service.app.impl;

import java.util.List;

import com.cxhc.system.domain.app.CmLike;
import com.cxhc.system.domain.cockpit.CmInfo;
import com.cxhc.system.mapper.app.CmInfomMapper;
import com.cxhc.system.mapper.app.CmLikeMapper;
import com.cxhc.system.service.app.ICmLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 点赞Service业务层处理
 * 
 * @author Dhq
 * @date 2024-09-24
 */
@Service
public class CmLikeServiceImpl implements ICmLikeService
{
    @Autowired
    private CmLikeMapper cmLikeMapper;

    @Autowired
    private CmInfomMapper cmInfomMapper;

    /**
     * 查询点赞
     * 
     * @param id 点赞主键
     * @return 点赞
     */
    @Override
    public CmLike selectCmLikeById(Long id)
    {
        return cmLikeMapper.selectCmLikeById(id);
    }

    /**
     * 查询点赞列表
     * 
     * @param cmLike 点赞
     * @return 点赞
     */
    @Override
    public List<CmLike> selectCmLikeList(CmLike cmLike)
    {
        return cmLikeMapper.selectCmLikeList(cmLike);
    }

    /**
     * 新增点赞
     * 
     * @param cmLike 点赞
     * @return 结果
     */
    @Override
    public int insertCmLike(CmLike cmLike)
    {
        int i = cmLikeMapper.insertCmLike(cmLike);
        cmInfomMapper.addlikeTotalById(cmLike.getTargetId());
        return i;
    }

    /**
     * 修改点赞
     * 
     * @param cmLike 点赞
     * @return 结果
     */
    @Override
    public int updateCmLike(CmLike cmLike)
    {
        return cmLikeMapper.updateCmLike(cmLike);
    }

    /**
     * 批量删除点赞
     * 
     * @param ids 需要删除的点赞主键
     * @return 结果
     */
    @Override
    public int deleteCmLikeByIds(Long[] ids)
    {
        return cmLikeMapper.deleteCmLikeByIds(ids);
    }

    /**
     * 删除点赞信息
     * 
     * @param id 点赞主键
     * @return 结果
     */
    @Override
    public int deleteCmLikeById(Long id)
    {
        int i = cmLikeMapper.deleteCmLikeById(id);
        cmInfomMapper.sublikeTotalById(String.valueOf(id));
        return i;
    }
}
